/*1942 game clone
 * Authors:
 * Abdollah Tabareh
 * Bharat Bhushan Konka
 * Martin Svensson 
 * Richard Zianne
 * Tigran Harutyunyan
 * 
 * 2010
*/

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;


namespace Game1942
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class EnemyPlane : FlyingObject
    {
        public int _planeWith { get; set; }
        public int _planeHight { get; set; }
        public float _planeSpeed { get; set; }
        protected List<Rectangle> frames;
        public bool _isDying { get; set; }
        public bool _isDead { get; set; }
        public int _index { get; set; }
        public Vector2 _direction { get; set; }
        private Game _game;
        
        public EnemyPlane(Game game)
            : base(game)
        {
            _game = game;
            
            // TODO: Construct any child components here
            //_position = new Vector2(0, 0);
            //_texture = texture;
            //screenBounds = new Rectangle(0, 0,
            //    Game.Window.ClientBounds.Width,
            //    Game.Window.ClientBounds.Height);
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here

            base.Initialize();
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here

            base.Update(gameTime);
        }
        /// <summary>
        /// Puts the plane in the uper left corner position
        /// </summary>
        public void putInPosition()
        {
            _position.X = 0;
            _position.Y = 0;
        }
        /// <summary>
        /// Puts the plane in a position
        /// </summary>
        /// <param name="xPosition">the x position of the plane</param>
        /// <param name="yPosition">the y position of the plane</param>
        public void putInPosition(float xPosition, float yPosition)
        {
            _position.X = xPosition;
            _position.Y = yPosition;
        }
        /// <summary>
        /// Puts the plane in a position
        /// </summary>
        /// <param name="position">the position of the plane</param>
        public void putInPosition(Vector2 position)
        {
            _position = position;
        }


        public List<Rectangle> Frames
        {
            get { return frames; }
            set { frames = value; }
        }
        /// <summary>
        /// Decrease the power of a plane with 10 
        /// </summary>
        public void hit()
        {
            hit(10);
        }
        /// <summary>
        /// Decrease the power of a plane with a variabel amont
        /// </summary>
        /// <param name="power">the amount of prower to decrease the plane with</param>
        public virtual void hit(int power)
        {
            decreasePower(power);
            if (_power <= 0)
            {
                _isDying = true;
            }
        }
        /// <summary>
        /// Fires a bullit
        /// </summary>
        public void fire()
        {
            //Bullet b = 
           //b.launch(_position, _direction);
        
        }

        public bool CheckCollisionRect(Rectangle rect)
        {
            Rectangle spriterect = new Rectangle((int)_position.X, (int)_position.Y, _planeWith, _planeHight);
            return spriterect.Intersects(rect);

        }
      

        public Rectangle BoundsRect()
        {
            return new Rectangle((int)_position.X, (int)_position.Y, (int)_planeWith, (int)_planeHight);
        }
        
    }
}